<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>配置主明细界面</title>
		<link rel="stylesheet" type="text/css"
			href="${pageContext.request.contextPath}/js/themes/default/easyui.css" />
		<link rel="stylesheet" type="text/css"
			href="${pageContext.request.contextPath}/js/themes/icon.css" />
		<link rel="stylesheet"
			href="${pageContext.request.contextPath}/homepages/css/main.css"
			type="text/css" />
		<script type="text/javascript"
			src="${pageContext.request.contextPath}/js/jquery-1.4.4.min.js"></script>
		<script type="text/javascript"
			src="${pageContext.request.contextPath}/js/jquery.easyui.min.1.2.2.js"></script>
		<script type="text/javascript"
			src="${pageContext.request.contextPath}/homepages/js/forms.js"></script>
		<script type="text/javascript">
 			 
			 var formId= "";
 			 $(function(){
 			 	$('#loadColumn').datagrid({
 			 		iconCls:'icon-save',
 			 		width:'500',
					nowrap: false,
					striped: true,				 
					collapsible:true,
					autoRowHeight: false,		
					sortName: 'code',
					sortOrder: 'desc',
					remoteSort: false,
					idField:'code',
					fitColumns:true,
					columns:[[  
					        {field:'code',title:'列英文名称',width:100},  
       						{field:'name',title:'列中文名称',width:100} 
   						 ]],
					pagination:true,
					rownumbers:true
 			 	})
 			 });
			 
			//添加列，并且根据传入的dsid 查询所有的相关数据
			function addColumns(){
				formId=$('#dsId').val();
				var readOnly=$('#readOnly').val();
				var required= $('#required').val();
				var singleRow= $('#singleRow').val();
				if(readOnly == 'on'){
					$('#readOnly').val('T');
				}else{
					$('#readOnly').val('F');
				}
				if(required == 'on'){
					$('#required').val('T');
				}else{
					$('#required').val('F');
				}
				if(singleRow == 'on'){
					$('#singleRow').val('T');
				}else{
					$('#singleRow').val('F');
				}
				$.ajax({
					type:'post',
					url:'${pageContext.request.contextPath}/sys/saveColumn?formId='+formId,
					data:$('#addCol').serialize(),
					dataType:'json',
                    success:function(data){
					    $.messager.alert("结果","设置成功！","OK",null);
					    endLoadColm(formId);
					},
					error:function(d){
						$.messager.alert("结果", "错了!", "info", null); 
					}
				});
			}
			
			function addButns(){
				formId=$('#dsId').val();
				$.ajax({
					type:'post',
					url:'${pageContext.request.contextPath}/sys/saveButns?formId='+formId,
					data:$('#addButn').serialize(),
					dataType:'json',
                    success:function(data){
					    $.messager.alert("结果","设置成功！","OK",null);
					    endLoadColm(formId);
					},
					error:function(d){
						$.messager.alert("结果", "错了!", "info", null); 
					}
				});
			}
			function saveSql(){
				formId=$('#dsId').val();
				$.ajax({
					type:'post',
					url:'${pageContext.request.contextPath}/sys/saveSql?formId='+formId,
					data:$('#addSql').serialize(),
					dataType:'json',
                    success:function(data){
					    $.messager.alert("结果","设置成功！","OK",null);
					    endLoadColm(formId);
					},
					error:function(d){
						$.messager.alert("结果", "错了!", "info", null); 
					}
				});
			}
			//等所有保存按钮执行后都要执行这个方法  刷新 显示页面
			function endLoadColm(formId){
				$('#columnsDiv1').load('${pageContext.request.contextPath}/mainList/uiformmainlist',
				{'formId':formId}); 
			}
 		</script>
	</head>

	<body>
		<span>表ID</span>
		<input type="text" name="dsid" id="dsId"/>
		<div class="easyui-panel" title="配置列信息" collapsible="true">
			<div style="width: 350px; float: left;">
				<form id="addCol">
					<table id="editform">
						<tr>
							<td colspan="2">
								<input type="button" value="添加" onclick="addColumns()" />
								<input type="button" value="重置" />
							</td>
						</tr>
						<tr>
							<td class="efn">
								<span>英文名</span>
							</td>
							<td>
								<input type="text" name="name" />
							</td>
						</tr>
						<tr>
							<td class="efn">
								<span>界面名称</span>
							</td>
							<td>
								<input type="text" name="colnName" />
							</td>
						</tr>
						<tr>
							<td class="efn" title="如果是分组名，则填写，否则不填写">
								组ID
							</td>
							<td>
								<input type="text" name="groupId" />
							</td>
						</tr>
						<tr>
							<td class="efn">
								<span>组名</span>
							</td>
							<td>
								<input type="text" name="groupName" />
							</td>
						</tr>
						<tr>
							<td class="efn">
								排序号
							</td>
							<td>
								<input type="text" name="orderNum" />
							</td>
						</tr>
						<tr>
							<td class="efn" colspan="2">
								<input type="checkbox" name="readOnly" id="readOnly"/>
								只读
								<input type="checkbox" name="required" id="required"/>
								必须
								<input type="checkbox" name="singleRow" id="singleRow" />
								独行
							</td>
						</tr>
						<tr>
							<td class="efn">
								宽度
							</td>
							<td>
								<input type="text" name="width" />
							</td>
						</tr>
						<tr>
							<td class="efn">
								长度
							</td>
							<td>
								<input type="text" name="height" />
							</td>
						</tr>
						<tr>
							<td class="efn">
								JAVA类
							</td>
							<td>
								<input type="text" name="javaClass" />
							</td>
						</tr>
						<tr>
							<td class="efn">
								JAVA属性
							</td>
							<td>
								<input type="text" name="javaProperty" />
							</td>
						</tr>
						<tr>
							<td class="efn">
								加载相似
							</td>
							<td>
								<input type="text" name="openLoadType" />
							</td>
						</tr>
					</table>
				</form>
			</div>
			<div style="width: 350px; float: left;">
				<form id="addButn">
					<table id="editform">
						<tr>
							<td colspan="2">
								<input type="button" value="添加" onclick="addButns()" />
								<input type="button" value="重置" />
							</td>
						</tr>
						<tr>
							<td class="efn">
								<span>英文名</span>
							</td>
							<td> 
								<input type="text" name="name" />
							</td>
						</tr>
						<tr>
							<td class="efn">
								<span>按钮名称</span>
							</td>
							<td>
								<input type="text" name="butnName" />
							</td>
						</tr>
						<tr>
							<td class="efn">
								排序号
							</td>
							<td>
								<input type="text" name="orderNum" />
							</td>
						</tr>
					</table>
				</form>
			</div>
		</div>
		<div class="easyui-panel" title="配置信息展示" collapsible="true">
			<div id="columnsDiv1">
			</div>
		</div>
	</body>
</html>
